package cn.stylefeng.guns.modular.business.controller;


import cn.stylefeng.guns.modular.business.pojo.ProjectScienceRequest;
import cn.stylefeng.guns.modular.business.service.ProjectScienceService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 工程科技控制器
 *
 * @author zhangyaowen
 * @date 2021/10/12 15:07
 */
@RestController
@ApiResource(name = "工程科技")
public class ProjectScienceController {

    @Resource
    private ProjectScienceService projectScienceService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @PostResource(name = "添加", path = "/projectScience/add")
    public ResponseData add(@RequestBody @Validated(ProjectScienceRequest.add.class) ProjectScienceRequest projectScienceRequest) {
        projectScienceService.add(projectScienceRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @PostResource(name = "删除", path = "/projectScience/delete")
    public ResponseData delete(@RequestBody @Validated(ProjectScienceRequest.delete.class) ProjectScienceRequest projectScienceRequest) {
        projectScienceService.del(projectScienceRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @PostResource(name = "编辑", path = "/projectScience/edit")
    public ResponseData edit(@RequestBody @Validated(ProjectScienceRequest.edit.class) ProjectScienceRequest projectScienceRequest) {
        projectScienceService.edit(projectScienceRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @GetResource(name = "查看详情", path = "/projectScience/detail")
    public ResponseData detail(@Validated(ProjectScienceRequest.detail.class) ProjectScienceRequest projectScienceRequest) {
        return new SuccessResponseData(projectScienceService.detail(projectScienceRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @GetResource(name = "获取列表", path = "/projectScience/list")
    public ResponseData list(ProjectScienceRequest projectScienceRequest) {
        return new SuccessResponseData(projectScienceService.findList(projectScienceRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/12 15:07
     */
    @GetResource(name = "分页查询", path = "/projectScience/page")
    public ResponseData page(String value,String river,String project) {
        return new SuccessResponseData(projectScienceService.findPage(value,river,project));
    }

    @GetResource(path = "/projectScience/findChoose")
    public ResponseData findChoose() {
        return new SuccessResponseData(projectScienceService.findChoose());
    }


    @GetResource(path = "/projectScience/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(projectScienceService.toReview(id));
    }
}